<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#main{
				width: 300px;
				height: 500px;
				margin: 200px auto;
			}
		</style>
	</head>

	<body>
		<div id="main">
		    <p>登录名：zhuye 密码：111111</p>
		    <p>登录名：admin 密码：111111</p>
			<p>登录名：<input type="text" id="loginname" value="" /></p>
			<p>登录密码：<input type="text" id="loginpwd" value="" /></p>
			<p><input type="button" name="" id="" value="登录" onclick="login()" /></p>
			<a href="register.html">立即注册</a>
		</div>
		<script src="js/jmessage-sdk-web-2.1.0.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/init.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			window.JIM = new JMessage({
//				debug: true,
			});
			window.onload = function() {
				init();
			}
			//登录功能
			function login() {
				var Lname = document.getElementById("loginname").value
				var Lpwd = document.getElementById("loginpwd").value
				JIM.login({
					'username': Lname,
					'password': Lpwd
				}).onSuccess(function(data) {
					console.log("登录成功")
					location.href = "self.html?username=" + Lname + "&password=" + Lpwd;
					Lname = ""
					Lpwd = ""
				}).onFail(function(data) {
					console.log('error:' + JSON.stringify(data));
				}).onTimeout(function(data) {
					console.log('timeout:' + JSON.stringify(data));
				});
			}

			
		</script>
	</body>

</html>